<?php


namespace App\Utils\Notice;


use App\Amqp\Producer\NoticeProducer;
use Hyperf\Amqp\Producer;

class Sender
{

    public static function send($receiveIds, Notice $notice,$isPushToMq = false)
    {
        if (!is_array($receiveIds)) {
            $receiveIds = [$receiveIds];
        }
        foreach ($receiveIds as $receiveId) {
            $notice->receiverId = $receiveId;
            if($isPushToMq){
                $message = new NoticeProducer([
                    'receive_id' =>$receiveId,
                    'data' => $notice->data,
                    'class_name' => get_class($notice)
                ]);
                di(Producer::class)->produce($message);
            }else{
                $notice->process();
            }
        }

    }
}